import request from "@/utils/request";

const api_name = "/admin/product/spec";

// 分页查询商品规格
export const GetProductSpecPageList = (pageNum, pageSize, specName) => {
  return request({
    url: "/admin/product/spec/page",
    method: "post",
    data: {
      pageNum,
      pageSize,
      specName
    }
  });
};

// 新增商品规格
export const SaveProductSpec = productSpec => {
  return request({
    url: `${api_name}/add`,
    method: "post",
    data: productSpec
  });
};

// 修改商品规格信息
export const UpdateProductSpecById = productSpec => {
  return request({
    url: `${api_name}/update`,
    method: "put",
    data: productSpec
  });
};

// 根据id删除商品规格
export const DeleteProductSpecById = id => {
  return request({
    url: `${api_name}/remove/${id}`,
    method: "post"
  });
};

// 根据商品规格名称查询信息
export const getProductSpecInfoByName = specName => {
  return request({
    url: `${api_name}/get?specName=${specName}`,
    method: "get" // 改为GET请求
  });
};

// 根据ID查询商品规格所有信息
export const getProductSpecInfoById = id => {
  return request({
    url: `${api_name}/${id}`,
    method: "get" // 改为GET请求
  });
};

// 获取全部商品规格
export const FindAllProductSpec = () => {
  return request({
    url: `${api_name}/get/all`,
    method: "get"
  });
};
